﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.Samples.Office.UnifiedCommunications.Gadget.Config
{
    public class GadgetSettingsSection : ConfigurationSection
    {
        #region Constructors

        static GadgetSettingsSection()
        {
            // used by the Exchange configuration screen
            s_EmailAddress = new ConfigurationProperty("emailAddress", typeof(string), null, ConfigurationPropertyOptions.None);
            s_ExchangeServer = new ConfigurationProperty("exchangeServer", typeof(string), null, ConfigurationPropertyOptions.None);
            s_DomainUser = new ConfigurationProperty("domainUser", typeof(string), null, ConfigurationPropertyOptions.None);
            s_Password = new ConfigurationProperty("password", typeof(string), null, ConfigurationPropertyOptions.None);
            s_EWSUrl = new ConfigurationProperty("ewsUrl", typeof(string), null, ConfigurationPropertyOptions.None);
            s_AutoDiscover = new ConfigurationProperty("autodiscover", typeof(bool), false, ConfigurationPropertyOptions.None);
            s_VoicemailEnabled = new ConfigurationProperty("voicemailEnabled", typeof(bool), null, ConfigurationPropertyOptions.None);
            s_DisplayName = new ConfigurationProperty("displayName", typeof(string), null, ConfigurationPropertyOptions.None);

            // used by the Top 5 weighting and selection screen
            s_Top5UseIM = new ConfigurationProperty("top5UseIM", typeof(bool), true, ConfigurationPropertyOptions.None);
            s_Top5UseCall = new ConfigurationProperty("top5UseCall", typeof(bool), true, ConfigurationPropertyOptions.None);
            s_Top5UseEmail = new ConfigurationProperty("top5UseEmail", typeof(bool), true, ConfigurationPropertyOptions.None);
            s_Top5UseTagged = new ConfigurationProperty("top5UseTagged", typeof(bool), true, ConfigurationPropertyOptions.None);
            s_Top5UseTeamMember = new ConfigurationProperty("top5UseTeamMember", typeof(bool), true, ConfigurationPropertyOptions.None);

            s_ContactsUpdated = new ConfigurationProperty("contactsUpdated", typeof(DateTime), DateTime.MinValue, ConfigurationPropertyOptions.None);
            s_Top5Updated = new ConfigurationProperty("top5Updated", typeof(DateTime), DateTime.MinValue, ConfigurationPropertyOptions.None);

            s_Fav5Collection = new ConfigurationProperty("Favorite5", typeof(FavoriteElementCollection), null, ConfigurationPropertyOptions.None);
            s_Top5Collection = new ConfigurationProperty("Top5", typeof(FavoriteElementCollection), null, ConfigurationPropertyOptions.None);
            s_ContactCollection = new ConfigurationProperty("Contacts", typeof(ContactElementCollection), null, ConfigurationPropertyOptions.None);
            s_DesktopContactCollection = new ConfigurationProperty("DesktopContacts", typeof(DesktopContactElementCollection), null, ConfigurationPropertyOptions.None);
            s_PresenceEventCollection = new ConfigurationProperty("PresenceEvents", typeof(PresenceEventElementCollection), null, ConfigurationPropertyOptions.None);

            s_properties = new ConfigurationPropertyCollection();
            s_properties.Add(s_EmailAddress);
            s_properties.Add(s_ExchangeServer);
            s_properties.Add(s_DomainUser);
            s_properties.Add(s_Password);
            s_properties.Add(s_EWSUrl);
            s_properties.Add(s_AutoDiscover);
            s_properties.Add(s_VoicemailEnabled);
            s_properties.Add(s_DisplayName);
            s_properties.Add(s_Top5UseIM);
            s_properties.Add(s_Top5UseCall);
            s_properties.Add(s_Top5UseEmail);
            s_properties.Add(s_Top5UseTagged);
            s_properties.Add(s_Top5UseTeamMember);
            s_properties.Add(s_ContactsUpdated);
            s_properties.Add(s_Top5Updated);
            s_properties.Add(s_Top5Collection);
            s_properties.Add(s_Fav5Collection);
            s_properties.Add(s_ContactCollection);
            s_properties.Add(s_DesktopContactCollection);
            s_properties.Add(s_PresenceEventCollection);
        }

        #endregion

        #region Static Fields
        private static ConfigurationProperty s_EmailAddress;
        private static ConfigurationProperty s_ExchangeServer;
        private static ConfigurationProperty s_DomainUser;
        private static ConfigurationProperty s_Password;
        private static ConfigurationProperty s_EWSUrl;
        private static ConfigurationProperty s_AutoDiscover;
        private static ConfigurationProperty s_VoicemailEnabled;
        private static ConfigurationProperty s_DisplayName;

        private static ConfigurationProperty s_Top5UseIM;
        private static ConfigurationProperty s_Top5UseCall;
        private static ConfigurationProperty s_Top5UseEmail;
        private static ConfigurationProperty s_Top5UseTagged;
        private static ConfigurationProperty s_Top5UseTeamMember;

        private static ConfigurationProperty s_ContactsUpdated;
        private static ConfigurationProperty s_Top5Updated;

        private static ConfigurationProperty s_Top5Collection;
        private static ConfigurationProperty s_Fav5Collection;
        private static ConfigurationProperty s_ContactCollection;
        private static ConfigurationProperty s_DesktopContactCollection;
        private static ConfigurationProperty s_PresenceEventCollection;

        private static ConfigurationPropertyCollection s_properties;
        #endregion

        #region Properties

        [ConfigurationProperty("EmailAddress")]
        public string EmailAddress
        {
            get { return (string)base[s_EmailAddress]; }
            set { base[s_EmailAddress] = value; }
        }

        [ConfigurationProperty("ExchangeServer")]
        public string ExchangeServer
        {
            get { return (string)base[s_ExchangeServer]; }
            set { base[s_ExchangeServer] = value; }
        }

        [ConfigurationProperty("DomainUser")]
        public string DomainUser
        {
            get { return (string)base[s_DomainUser]; }
            set { base[s_DomainUser] = value; }
        }

        [ConfigurationProperty("Password")]
        public string Password
        {
            get { return (string)base[s_Password]; }
            set { base[s_Password] = value; }
        }

        [ConfigurationProperty("EWSUrl")]
        public string EWSUrl
        {
            get { return (string)base[s_EWSUrl]; }
            set { base[s_EWSUrl] = value; }
        }

        [ConfigurationProperty("Autodiscover")]
        public bool? Autodiscover
        {
            get { return (bool?)base[s_AutoDiscover]; }
            set { base[s_AutoDiscover] = value; }
        }

        [ConfigurationProperty("VoicemailEnabled")]
        public bool? VoicemailEnabled
        {
            get { return (bool?)base[s_VoicemailEnabled]; }
            set { base[s_VoicemailEnabled] = value; }
        }

        [ConfigurationProperty("DisplayName")]
        public string DisplayName
        {
            get { return (string)base[s_DisplayName]; }
            set { base[s_DisplayName] = value; }
        }

        [ConfigurationProperty("Top5UseIM")]
        public bool Top5UseIM
        {
            get { return (bool)base[s_Top5UseIM]; }
            set { base[s_Top5UseIM] = value; }
        }

        [ConfigurationProperty("Top5UseCall")]
        public bool Top5UseCall
        {
            get { return (bool)base[s_Top5UseCall]; }
            set { base[s_Top5UseCall] = value; }
        }

        [ConfigurationProperty("Top5UseEmail")]
        public bool Top5UseEmail
        {
            get { return (bool)base[s_Top5UseEmail]; }
            set { base[s_Top5UseEmail] = value; }
        }

        [ConfigurationProperty("Top5UseTagged")]
        public bool Top5UseTagged
        {
            get { return (bool)base[s_Top5UseTagged]; }
            set { base[s_Top5UseTagged] = value; }
        }

        [ConfigurationProperty("Top5UseTeamMember")]
        public bool Top5UseTeamMember
        {
            get { return (bool)base[s_Top5UseTeamMember]; }
            set { base[s_Top5UseTeamMember] = value; }
        }

        [ConfigurationProperty("Top5Updated")]
        public DateTime Top5Updated
        {
            get { return (DateTime)base[s_Top5Updated]; }
            set { base[s_Top5Updated] = value; }
        }

        [ConfigurationProperty("ContactsUpdated")]
        public DateTime ContactsUpdated
        {
            get { return (DateTime)base[s_ContactsUpdated]; }
            set { base[s_ContactsUpdated] = value; }
        }

        protected override ConfigurationPropertyCollection Properties
        {
            get
            {
                return s_properties;
            }
        }

        [ConfigurationProperty("Favorite5")]
        public FavoriteElementCollection Favorite5
        {
            get { return (FavoriteElementCollection)base[s_Fav5Collection]; }
        }

        [ConfigurationProperty("Top5")]
        public FavoriteElementCollection Top5
        {
            get { return (FavoriteElementCollection)base[s_Top5Collection]; }
            set { base[s_Top5Collection] = value; }
        }

        [ConfigurationProperty("Contacts")]
        public ContactElementCollection Contacts
        {
            get { return (ContactElementCollection)base[s_ContactCollection]; }
        }

        [ConfigurationProperty("DesktopContacts")]
        public DesktopContactElementCollection DesktopContacts
        {
            get { return (DesktopContactElementCollection)base[s_DesktopContactCollection]; }
        }

        [ConfigurationProperty("PresenceEvents")]
        public PresenceEventElementCollection PresenceEvents
        {
            get { return (PresenceEventElementCollection)base[s_PresenceEventCollection]; }
        }

        #endregion
    }
}
